/**
 * Created by wangshaohua on 2018/1/28.
 */
moduleDoor.controller("DoorQuery", function (LanguageService, $scope, $log, $state, LoadingService, ConstantService, DialogService, EventResource) {
    initPage($scope);
    $scope.$on("$viewContentLoaded", function () {
        pageOnLoad();
        ConstantService.addState($state.current, true, LanguageService.language('传送门管理'));
        $scope.pagination = new Pagination();
        $scope.pagination.setPageClickFn($scope.queryDoor);
        $scope.queryDoor($scope.pagination.currentPageNo);
    });

    $scope.onQueryKeyDown = function () {
        if (event.keyCode == 13) {
            $scope.queryDoor(1);
        }
    }

    $scope.queryPara = {};
    $scope.queryDoor = function (pageNo) {
        //LoadingService.show();
        EventResource.queryPage({pageNo: pageNo - 1, pageSize: 10, type: 'STUDY_MAP'}, $scope.queryPara, function (queryResult) {
            $log.debug("查询结果", queryResult);
            $scope.queryResult = queryResult;
            $scope.pagination.setPage(queryResult, pageNo);
            //LoadingService.hide();
        });
    };

    $scope.addDoor = function () {
        DialogService.open("addDoor", $scope, function(){
            $scope.queryDoor(1);
        });
    };

    $scope.editDoor = function (door) {
        $scope.currentData = door;
        DialogService.open("editDoor", $scope, function(){
            $scope.queryDoor(1);
        });
    };

    $scope.refresh = function () {
        $scope.queryPara = {};
    };

});